package javamailclient;

import java.awt.Frame;
import java.io.IOException;
import javax.mail.BodyPart;
import javax.mail.MessagingException;
import javax.swing.BorderFactory;
import javax.swing.JDialog;
import javax.swing.JEditorPane;
import javax.swing.JLabel;
import javax.swing.JPanel;

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
/**
 *
 * @author Abigail
 */
public class loadingDlg extends JDialog {

    public loadingDlg(Frame parent) {
        // Call super constructor, specifying that dialog is modal.
        super(parent, true);

        // Set dialog title.
        setTitle("Loading Email From Server");

        // Instruct window not to close when the "X" is clicked.
        setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);

        // Put a message with a nice border in this dialog.
        JPanel contentPane = new JPanel();
        contentPane.setBorder(
                BorderFactory.createEmptyBorder(5, 5, 5, 5));
        contentPane.add(new JLabel("Loading messages..."));
        setContentPane(contentPane);

        // Size dialog to components.
        pack();

        // Center dialog over application.
        setLocationRelativeTo(parent);
    }

    public loadingDlg(Frame parent,String contentType, String content) throws MessagingException, IOException{// ) {
        super(parent, true);
        // Set dialog title.
        setTitle("View Multipart Content");
        // Instruct window not to close when the "X" is clicked.
        setDefaultCloseOperation(DISPOSE_ON_CLOSE);

        // Put a message with a nice border in this dialog.
        JPanel contentPane = new JPanel();
        contentPane.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
        contentPane.setAutoscrolls(true);

        //String contentType = bodyPart.getContentType();
        //byte[] buff = bodyPart.getDataHandler().getBaseType().getBytes();
        //Object content = bodyPart.getContent();
        
        JEditorPane editor = new JEditorPane(contentType, content);//.toString());
        //editor.setAutoscrolls(true);
        editor.setEditable(false);
        contentPane.add(editor);
        setContentPane(contentPane);

        // Size dialog to components.
        pack();

        // Center dialog over application.
        setLocationRelativeTo(parent);
    }
}
